package com.etl.dataflow.executor.element;

import lombok.ToString;

import java.sql.Date;
import java.sql.Timestamp;

/**
 * @author dx
 * @since 2022/4/14
 */
@ToString(callSuper = true)
public class StringColumn extends Column<String> {

    public StringColumn(String name, String value, int jdbcType, String jdbcTypeName) {
        super(name, value, jdbcType, jdbcTypeName);
    }

    @Override
    public String asString() {
        return super.getValue();
    }

    @Override
    public byte[] asBytes() {
        return super.value == null ? null : super.getValue().getBytes(super.getCharset());
    }

    @Override
    public Timestamp asTimestamp() {
        return null;
    }

    @Override
    public Date asDate() {
        return null;
    }

    @Override
    public int getByteSize() {
        return value == null ? 0 : value.length() * 3;
    }
}
